﻿// 1.1.6.06. Write a program that calculates N!/K! for given N and K (1<K<N).

using System;

class FactorialDivision
{
    static void Main()
    {
        Console.Write("N: ");
        int dividend = int.Parse(Console.ReadLine());   // N
        Console.Write("K: ");
        int divisor = int.Parse(Console.ReadLine());    // K
        if (dividend > 1 && divisor > 1)                // (1<K<N)
        {
            if (divisor > dividend)                     // assuring the condition (K<N)
            {
                divisor += dividend;
                dividend = divisor - dividend;
                divisor -= dividend;
            }

            for (int i = dividend - 1, dividendCalculations = dividend; i > 1; i--) // calculating factorial
            {
                dividendCalculations *= i;  // a variable for calculations inside the loop for better performance
                if (i == 2) // checking for the end of the loop to assign the calculated value to a variable outside the loop
                {
                    dividend = dividendCalculations;
                }
            }
            for (int i = divisor - 1, divisorCalculations = divisor; i > 1; i--)
            {
                divisorCalculations *= i;
                if (i == 2)
                {
                    divisor = divisorCalculations;
                }
            }

            Console.WriteLine(dividend / divisor);
        }
        else
        {
            Console.WriteLine("You didnt accomplish the condition (1<K<N).");
        }



    }
}
